#ifndef TABLEROWCELLGROUP_H
#define TABLEROWCELLGROUP_H

#include <QObject>
#include <QTableWidget>
#include <QTableWidgetItem>
#include "../Cell/CellBase.h"
#include <QMetaObject>

class ColumnInfo
{
public:
    ColumnInfo() {
        _cellBlock = nullptr;
    }
    ColumnInfo(const ColumnInfo &info) {
        *this = info;
    }
    virtual ~ColumnInfo() {}

    void operator=(const ColumnInfo &info){
        _name = info._name;
        _title = info._title;
        _cellMeta = info._cellMeta;
        _cellBlock = info._cellBlock;
    }

    QString _name;
    QString _title;
    QMetaObject _cellMeta;
    std::function<CellBase*(void)> _cellBlock;
};

class TableRowCellGroup : public QObject{
    Q_OBJECT
public:
    TableRowCellGroup(QTableWidget *tableWidget, int row, const QList<ColumnInfo> &columnInfoList, const QVariantMap &data);
    virtual ~TableRowCellGroup();

    void updateData(const QVariantMap &data);
    void setData(const QVariantMap &data);
    QVariantMap getData();
    void delData();

    void setSelected(bool selected);
    bool isSelected();
    void setActived(bool actived);
    bool isActived();

signals:
    void sigEvent(QString name, QVariant info);
    void sigDataChanged();

private:
    void installCell(QTableWidget *tableWidget, int row);
    Q_SLOT void onDataChanged();

private:
    QVariantMap _data;
    //int _row;
    QList<ColumnInfo> _columnInfoList;
    QMap<QString,CellBase*> _nameToCell;
};

#endif
